<template>
	<view class="container">
		<!-- 列表 -->
		<view class="coin-section m-t">
			<view class="s-row">
				<view class="col">
					<image  mode="widthFix" class="icon"></image>
					<text class="coin">币种：USDT</text>
				</view>
			<!-- 	<view class="col r light" >
					<text class="subtitle">提现币种</text>
					<uni-icons type="forward" size="20" class="arrow"></uni-icons>
				</view> -->
			</view>
			
			
			<view class="form">
				<text class="label">提币地址</text>
				<view class="input little-line">
					<input type="text" v-model="dataInfo.way" placeholder="输入或长按粘贴地址" class="address"/>
				</view>
				
				
				
				<text class="label">数量</text>
				<view class="input little-line">
					<input type="number" v-model="dataInfo.money" placeholder="请输入提币数量" class="address"/>
					<view class="all" @click="all">全部</view>
				</view>
				<view class="balance">可用 {{ userinfo.uMoney }} USDT</view>
				<text class="label">手续费 {{userinfo.timoneyfei}} </text>
			</view>
			
			
			
			<u-button type="primary" class="u-margin-top-40" @click="submit" :disabled="issubmit">确认</u-button>
			<!-- <button class="submit" @click="submit" :disabled="issubmit">确认</button> -->
		<!-- 	<view class="desc" v-html="tips[0] ? tips[0].content : ''"></view> -->
		</view>
	
	</view>
</template>

<script>
import validate from '@/common/ys-validate.js';
	export default {
		data() {
			return {
				dataInfo: {
					money: '',
					way:''
				},
				loadpic: '', //用户上传的图片
				getimg: this.$getimg,
				issubmit: false,
				userinfo: {}
			};
		},
	
		onLoad() {
			this.getInfo();
		},
	
		onPullDownRefresh() {
			// 下拉监听事件
			this.getInfo();
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
		},
	
		computed: {},
		methods: {
			getInfo(e) {
				this.$api.http.post('assistance/moneychange/getWithdrawalInfo').then(res => {
					if (res.status == 200) {
						this.userinfo = res.data;
					} else {
						this.$api.msg('获取失败');
						return false;
					}
				});
			},
			pay_chage(e) {
				this.dataInfo.way = e.detail.value;
			},
			
			
			
		all(){
			this.dataInfo.money =  parseInt(this.userinfo.uMoney) ;
		},
	
			submit() {
				if (!validate.isNumber(this.dataInfo.money) || this.dataInfo.money==0) {
					this.$api.msg('USDT输入有误');
					return false;
				}else
				  this.dataInfo.money =  parseInt(this.dataInfo.money) ;
	
				if (parseFloat(this.dataInfo.money) > this.userinfo.uMoney) {
					this.$api.msg('USDT不能大于'+this.userinfo.uMoney );
					return false;
				}
	
				if (this.dataInfo.way == '') {
					this.$api.msg('请输入提币地址');
					return false;
				}
				
			
	
				this.issubmit = true; //禁用按钮
				var _self = this;
			
				this.$api.http.post('assistance/moneychange/withdrawal', this.dataInfo).then(res => {
					if (res.status == 200) {
						//成功执行
						uni.showToast({
							icon: 'none',
							title: res.msg,
							mask: true,
							success() {
								setTimeout(() => {
								uni.removeStorageSync('my');//清除我的信息
									uni.navigateBack();
								}, 1000);
							}
						});
					} else {
						_self.issubmit = false; //启用按钮
						uni.showToast({
							icon: 'none',
							title: res.msg,
							mask: true
						});
	
						return false;
					}
				});
			}
		}
	};
	</script>

<style lang='scss' scoped>
	.container{
		padding: $page-row-spacing;
	}
	.coin-section{
		background: $bg-theme;
    color: $color-theme;
		.s-row{
			background-color: $bg-gap;
			display:flex;
			align-items:center;
			padding: 20upx 10upx 20upx 10upx;
			.col{
				font-size: $font-lg;
				color: $text-color;
				flex:1;
				.icon{
					width: 60upx;
					height: 60upx;
					vertical-align: middle;
					margin-right: 10upx;
				}
				.coin{
					font-weight: 400;
					vertical-align: middle;
				}
				.subtitle{
					font-size: $font-lg;
					font-weight: 400;
				}
			}
			.coinLogo {
			    width: 46upx;
				height: 46upx;
			    margin-right: 8px;
			    display: inline-block;
			    vertical-align: middle;
			    float: left;
			}
			.light{
				font-weight: 100;
				font-size: $font-lg;
				color: $text-color;
			}
			.r{
				text-align: right;
			}
			.arrow{
				vertical-align: middle;
			}
		}
		.form{
			padding: 10upx 0;

			display: flex;
			flex-direction: column;
			.label{
				margin-top: 30upx;
				color: $text-color;
				font-size: 40upx;
			}
			.balance{
				margin-top: 10upx;
				color: $font-color-light;
				font-size: $font-lg;
			}
			.input{
				padding: 10upx 0;
				display: flex;
				flex-direction: row;
				justify-content: space-between;
				.all{
					flex: 0.5;
					text-align: right;
					font-size: 40upx;
					color: $text-color;
					font-weight: bold;
				}
			}
			input{
				color: $font-color-light;
				font-size: 40upx;
				height: 50upx;
			}
		}
		.desc{
			margin-top: 30upx;
			margin-bottom: 20upx;
			font-size: $font-base;
			color: $color-theme;
			display: flex;
			flex-direction: column;
		}
	}
	.submit{
		margin: 60upx 0upx;
		background: $uni-color-blue;
		color: #fff;
		font-size: $font-md;
	}
	
	

</style>
